package hgx.spring.cloud.lession.demo;/**
 * Created by liujun on 2018/4/20.
 */

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import hgx.spring.cloud.lession.demo.a.AFactory;
import hgx.spring.cloud.lession.demo.a.IAdemo;
import hgx.spring.cloud.lession.demo.b.BFactory;
import hgx.spring.cloud.lession.demo.b.IBdemo;

/**
 * @author Administrator
 * @create 2018-04-20 9:38
 */
public class Test {

    public static void main(String[] args) {

        test2();
//        test3();

    }

    public static  void test1(){
        IDemoOne demoOne=new DemoOneImpl();
        demoOne.one();
        demoOne.three();
        demoOne.three();
    }
    public static  void test2(){
        IAdemo ademo= AFactory.createADemo();
        ademo.one();
        ademo.one("可以测试了");
        ademo.one(123,"张三");
        ademo.three();
    }
    public static  void test3(){
        IBdemo bdemo= BFactory.createBedemo();
        bdemo.two();
    }
    public static  void test4() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {

        String methName="one";
        DemoOneImpl demoOne=new DemoOneImpl();
        Class clazz=demoOne.getClass();
        Object [] args=new Object[1];
        args[0]="abc";
        Method adapterMehtod=clazz.getMethod(methName,String.class);


        String str="";
        if(adapterMehtod !=null ){
            str= (String) adapterMehtod.invoke(demoOne,args);
        }
        System.out.println("结果：  "+str);
    }
}
